# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-base
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.6.3
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="https://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            )
depends=("${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-libvorbis"
         "${MINGW_PACKAGE_PREFIX}-libtheora"
         "${MINGW_PACKAGE_PREFIX}-libvorbisidec"
         "${MINGW_PACKAGE_PREFIX}-pango"
         #"${MINGW_PACKAGE_PREFIX}-libvisual"
         #"${MINGW_PACKAGE_PREFIX}-cdparanoia"
         "${MINGW_PACKAGE_PREFIX}-gstreamer"
         "${MINGW_PACKAGE_PREFIX}-orc"
        )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
        0002-fix-test-running.mingw.patch
        0006-disable-sse-detection.mingw.patch)
sha256sums=('b6154f8fdba4877e95efd94610ef0ada4f0171cd12eb829a3c3c97345d9c7a75'
            'b2e6a52035fd568e58ca4561dd1aeaffb81f7e1bf72fb01478613766d662d168'
            '7c00f57f987b45f2f4c17d7c58f98eb4dace6f4ab198b7e562994aa2183ee70c')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  patch -p1 -i ${srcdir}/0006-disable-sse-detection.mingw.patch
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
